package com.exposit.zbs.dao.base;

import org.hibernate.criterion.Criterion;

import java.util.List;
import java.util.Map;


/**
 * Interface for DAO application layer.
 *
 * @param <T>  Entity type
 * @param <PK> Type for primary key
 * @author Andrey
 */
public interface IBaseDAO<T, PK extends java.io.Serializable> {

	/**
	 * This method for find all entities in database table
	 *
	 * @return List of entities
	 */
	List<T> findAll();

	/**
	 * This method for finding entity by ID.
	 *
	 * @param id Id of entity
	 * @return Finded entity.
	 */
	T findById(PK id);

	/**
	 * This method for finding entity in table by criteria.
	 *
	 * @param criterion
	 *            Criteria of selecting.
	 * @return List of entities.
	 */

	/**
	 * Method for updating entity in db.
	 *
	 * @param updatedEntity Updated entity.
	 */
	void update(T updatedEntity);

	/**
	 * This method for save entity in Database.
	 *
	 * @param savedEntity Entity for saving
	 * @return Primary key of entity in database, if entity is saved.
	 */
	void delete(T deletedEntity);

	/**
	 * This method for deleting entity of
	 *
	 * @param deletedEntity Entity for deleting.
	 */

	PK save(T savedEntity);

	List<T> findByCriteria(Criterion... criterion);

	void delete(PK id);

	List<T> executeNamedQueryList(String name, Map<String, String> params);

	T executeNamedQuery(String name, Map<String, String> params);
}
